package org.logstashplugins.config;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

/**
 * 插件数据源配置
 */
public class PluginDataSourceConfig {

    private static HikariDataSource ds;

    static {
        //实例化类
        HikariConfig hikariConfig = new HikariConfig();
        //设置url
        hikariConfig.setJdbcUrl("jdbc:mysql://106.53.243.191:23306/regex_schema?" +
                "useUnicode=true&characterEncoding=utf-8&" +
                "allowMultiQueries=true&useSSL=false&serverTimezone=UTC");
        //数据库帐号
        hikariConfig.setUsername("root");
        //数据库密码
        hikariConfig.setPassword("Zxz19981201@");
        hikariConfig.setDriverClassName("com.mysql.jdbc.Driver");
        hikariConfig.addDataSourceProperty("cachePrepStmts", "true");
        hikariConfig.addDataSourceProperty("prepStmtCacheSize", "250");
        hikariConfig.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
        ds = new HikariDataSource(hikariConfig);
    }

    public static HikariDataSource getDataSource(){
        return ds;
    }

}
